library(tidyverse)
library(usmap)
library(readstata13)  
library(scales)
setwd("C:/Users/aguo/Documents/UIProject/RESTAT")

############ FIGURE 1 ###################
uitax <- read.dta13("uitax.dta")
uitax <- subset(uitax,uitax$year==2008)
uitax$maxtax[uitax$maxtax>2000] <- 2000
table <- data.frame("fips" = uitax$state, "max" = uitax$maxtax)
adjusted_map <- plot_usmap(data = table, values = "max")
adjusted_map + theme(legend.position = c(0.925, 0.175)) + labs(fill = "Maximum Tax") + scale_fill_distiller(breaks = pretty_breaks(n = 5), trans = "reverse")

############ FIGURE A.3 ###################
data <- read.csv("samplemap.csv")
table <- data.frame("fips" = data$fips, "val" = data$share)
adjusted_map <- plot_usmap(data = table, values = "val")
adjusted_map + theme(legend.position = c(0.925, 0.175)) + labs(fill = "State Share") + scale_fill_distiller(breaks = pretty_breaks(n = 5), trans = "reverse")
